package org.example.my.service;

import org.example.my.mapper.BlogMapper;
import org.example.my.model.BlogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogService {
    @Autowired
    BlogMapper blogMapper;
    public List<BlogInfo> selectBlogList() {
        return blogMapper.selectBlogList();
    }

    public BlogInfo selectBlogById(Integer id) {
        return blogMapper.selectBlogById(id);
    }

    public Integer selectUserIdById(Integer blogId) {
        return blogMapper.selectUserIdById(blogId);
    }

    public Integer updateBlog(BlogInfo blogInfo) {
        return blogMapper.updateBlog(blogInfo);
    }

    public Integer insertBlog(BlogInfo blogInfo) {
        return blogMapper.insertBlog(blogInfo);
    }

    public Integer selectBlogCount(Integer blogId) {
        Integer userId = blogMapper.selectUserIdById(blogId);
        return blogMapper.selectBlogCount(userId);
    }
}
